const  http = require('http');

const server = http.createServer();

server.on('request',(req,res) => {

    if(req.url === '/') {
        res.setHeader('Content-Type','text/html;charset=utf-8');
        res.setHeader('Content-length',10);
        res.setHeader('Transfer-Encoding','chunked');
        res.write('<h1>daxia</h1>');

        setTimeout(() => {
            res.write('<p>第一次传输</p>');
        },1000);

        setTimeout(() => {
            res.write('<p>第二次传输</p>');
            res.end();
        },6000);

        
    }
})


server.listen(1314,() => {
    console.log(`服务在 http://localhost:${1314} 上启动起来了`);
})